#!/bin/bash
nginxurl=/opt/openresty/nginx
. $nginxurl/scripts/golo.conf
rosnode kill /mo_calibrator
pkill -f calib.launch
pkill -f cam_calib.launch
if [ -d /home/nuc/.rtk_ws ];then
    source $ROS_RTK_WS_PATH
else
   source $ROS_ASLAM_WS_PATH
fi
RosCron=$(sudo service cron status |grep running |wc -l)
if [ $RosCron == 1 ];then
    sudo service cron  stop 
fi
RosWM=$(rosnode list|grep golo_monitor |wc -l)
if [ $RosWM == 1 ];then
	sudo systemctl stop goloWM ; echo y |rosnode cleanup	
fi
moak_version=$(rosversion moak_cam_scan |awk -F'.' '{print $1 $2}')
RosC=$(rosnode list|grep mo_camera |wc -l)
roscd moak_cam_scan
moak_dir=$(pwd)
if [ $moak_version -ge 22 ];then
sudo sed -i 's#<param name="ENABLE_DRIVER_NODE_DEBUG_OUTPUT"  type="int" value="0" />#<param name="ENABLE_DRIVER_NODE_DEBUG_OUTPUT"  type="int" value="1" />#' $moak_dir/launch/mo_camera_scan.launch;sudo systemctl restart goloC
else	
	sudo systemctl stop goloC;echo y |rosnode cleanup 
fi
sleep 5
moak_version=$(rosversion moak_cam_scan |awk -F'.' '{print $1 $2}')
if [ $moak_version != 22 ];then
roslaunch moak_calib  start_calib_front.launch &
fi
